<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>前置征信--查看</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div style="display:none;">
    <div class="field">
        <!-- 客户主键 -->
        <input name="zx_cstid" id="zx_cstid" type="text" class="ui-textbox" value="${zx_cstid}">
        <!-- 图片服务器根服务 -->
        <input name="zx_pathid" id="zx_pathid" type="text" class="ui-textbox" value="${zx_path}">
    </div>
</div>

<div class="sqPanel">
    <div class="sqPanel_head inL">
        <span>第三方征信(承租人)</span>
    </div>
    <div class="sqPanel_body">
        <div class="sq-staticGrid">
            <table class="table_full">
                <thead>
                <tr>
                    <td width="20%">公司名称</td>
                    <td width="10%">状态</td>
                    <td width="40%">描述</td>
                    <td width="30%">操作</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>信加</td>
                    <td id="xjsId${zx_cstid}">&nbsp;</td>
                    <td id="xjDescId${zx_cstid}">&nbsp;</td>
                    <td id="xjOper" style="text-align:left;padding-left: 20px;">

                        <sys:funcAuth resCd="showRhCorpReport">
                            <a href="javascript:;" onclick="xjShow(${zx_cstid},'');">报告</a>
                        </sys:funcAuth>
                    </td>
                </tr>
                <tr>
                    <td>小秘拒单规则</td>
                    <td id="refuseId${zx_cstid}">&nbsp;</td>
                    <td id="refuseDescId${zx_cstid}">&nbsp;</td>
                    <td id="refuseOper" style="text-align:left;padding-left: 20px;">
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<br>

<!-- 动态数据 -->
<div id="zx_dym_div_id">&nbsp;</div>

<script>
    $(function () {
        var _cstId = $("#zx_cstid").val();
        // 传统业务拒绝规则
        initData(_cstId);
        // 信加
        // refXjData(_cstId);
        refXjLocalDataBaseData(_cstId);  // 信加数据
    });
    var pathMap = new HashMap();// 记录对应的报告路径
    // 修改初始化数据
    function initData(_cstId) {
        var _url = '<%=path%>/corp/rccstcorpbscinfo/getRiskCtrlData.do';
        AjaxUtils.ajaxGet(_url, {cstId: _cstId}, function (msg) {
            if (msg.success == 1) {
                setData(msg.data, _cstId);
            } else {
                //UIUtils.alertError(msg.info);
            }
        });
    }
    //修改时候设置页面数据
    function setData(data, _cstId) {
        var json = eval(data);
        // setXjData(json, _cstId);
        setRefuseData(json, _cstId);
    };

    //重新查信加数据
    <%--function refXjData(_cstId) {--%>
        <%--var _url = '<%=path%>/riskctrl/rccstbscinfo/getXjIsCorrectData.do';--%>
        <%--AjaxUtils.ajaxGet(_url, {cstId: _cstId}, function (msg) {--%>
            <%--if (msg.success == 1) {--%>
                <%--var json = eval(msg.data);--%>
                <%--setXjData(json, _cstId);--%>
                <%--//UIUtils.alertError(msg.info);--%>
            <%--}--%>
        <%--});--%>
    <%--}--%>
    //查信加本地库中数据
    function refXjLocalDataBaseData(_cstId) {
        var _url = '<%=path%>/corp/rccstcorpbscinfo/getXjCorpLocalData.do';
        AjaxUtils.ajaxGet(_url, {cstId: _cstId}, function (msg) {
            if (msg.success == 1) {
                var json = eval(msg.data);
                setXjData(json, _cstId);
            } else {
                //UIUtils.alertError(msg.info);
            }
        });
    }
    function setXjData(json, _cstId) {
        pathMap.remove("xj" + _cstId);//先删除
        console.log("查看结果：" + json["xj-pass"]);
        if ("false" == json["xj-pass"]) {
            $("#xjsId" + _cstId).html("<font color='#D70000'>&nbsp;</font>");
        } else if ("true" == json["xj-pass"]) {
            $("#xjsId" + _cstId).html("<font color='#00A900'>通过</font>");
        } else if ("review" == json["xj-pass"]) {
            $("#xjsId" + _cstId).html("<font color='#D70000'>复议</font>");
        } else if ("true" == json["xj-exception"]) {
            $("#xjsId" + _cstId).html("<font color='#D70000'>异常</font>");
        } else {
            $("#xjsId" + _cstId).html("<font color='#D70000'>未知</font>");
        }
        $("#xjDescId" + _cstId).html(json["xj"]);
        pathMap.put("xj" + _cstId, json["xj-path"]);
    }
    function setRefuseData(json, _cstId) {
        pathMap.remove("synthscr" + _cstId);//先删除
        if ("false" == json["refuse-pass"]) {
            $("#refuseId" + _cstId).html("<font color='#D70000'>审核未通过</font>");
        } else if ("true" == json["refuse-pass"]) {
            $("#refuseId" + _cstId).html("<font color='#00A900'>审核通过</font>");
        } else if ("audit" == json["refuse-pass"]) {
            $("#refuseId" + _cstId).html("<font color='#00A900'>审核中</font>");
        } else if ("commit" == json["refuse-pass"]) {
            $("#refuseId" + _cstId).html("<font color='#00A900'>待审核</font>");
        } else if ("audit1" == json["refuse-pass"]) {
            $("#refuseId" + _cstId).html("<font color='#00A900'>信审审核中</font>");
        } else if ("audit2" == json["refuse-pass"]) {
            $("#refuseId" + _cstId).html("<font color='#00A900'>三方数据审核中</font>");
        } else {
            $("#refuseId" + _cstId).html("<font color='#D70000'>未知</font>");
        }
        $("#refuseDescId" + _cstId).html(json["refuse"]);
    }
    
  	//信加报告
    function xjShow(_cstId) {
        var key = "xj" + _cstId;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("xj" + key, "个人信用报告", url);
    }
    //返回完整路径
    function getUrl(url) {
        var p = $("#zx_pathid").val();
        return p + url;
    }

</script>
</body>
</html>